//
//  SMSLogInView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/31.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class SMSLogInView: UIView {
    var phoneNumber:UITextField!//电话号码输入框
    var vCodeTF:UITextField!//验证码输入框
    var logButton:UIButton!//登录按钮
    var provingButton:UIButton!//获取验证码按钮
    
    
    override init(frame: CGRect) {
        phoneNumber = UITextField()
        vCodeTF = UITextField()
        logButton = UIButton()
        provingButton = UIButton()
        super.init(frame: frame)
        self.createPhoneNVCodeTextF()
        self.createLogButton()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.phoneNumber.resignFirstResponder()
        self.vCodeTF.resignFirstResponder()
    }
    
    //创建 手机号和验证码输入框 和 获取验证码按钮
    func createPhoneNVCodeTextF(){
        phoneNumber.frame = CGRect(x: 32*SCALEW, y: 27*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        phoneNumber.placeholder = "请输入手机号"
        phoneNumber.keyboardType = .NumberPad
        phoneNumber.font = BaseFunc.getSystemFont(14.5)
        phoneNumber.backgroundColor = UIColor.whiteColor()
        let view1 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        phoneNumber.leftView = view1
        phoneNumber.leftViewMode = .Always
        phoneNumber.layer.borderWidth = 1
        phoneNumber.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        phoneNumber.layer.cornerRadius = 5
        self.addSubview(phoneNumber)
        
        vCodeTF.frame = CGRect(x: 32*SCALEW, y: 82*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        vCodeTF.placeholder = "请输入验证码"
        vCodeTF.keyboardType = .NumberPad
        vCodeTF.font = BaseFunc.getSystemFont(14.5)
        vCodeTF.backgroundColor = UIColor.whiteColor()
        let view2 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        vCodeTF.leftView = view2
        vCodeTF.leftViewMode = .Always
        vCodeTF.layer.borderWidth = 1
        vCodeTF.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        vCodeTF.layer.cornerRadius = 5
        vCodeTF.secureTextEntry = true
        self.addSubview(vCodeTF)
        
        
        //获取验证码按钮
        provingButton.frame = CGRect(x: WidthAPP-37*SCALEW-100*SCALEW,y: 32*SCALEH,width: 100*SCALEW,height: 29*SCALEH)
        provingButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState())
        provingButton.setTitle("发送验证码", forState: UIControlState())
        provingButton.titleLabel?.font = BaseFunc.getCustomFont(12)
        provingButton.backgroundColor = UIColor.redColor()
        provingButton.layer.cornerRadius = 5
        self.addSubview(provingButton)
    }
    
    //创建登录按钮
    func createLogButton(){
        logButton.frame = CGRect(x: 33*SCALEW, y: 145*SCALEH, width: 309*SCALEW, height: 50*SCALEH)
        logButton.titleLabel?.font = BaseFunc.getCustomFont(18)
        logButton.setTitle("登录", forState: UIControlState())
        logButton.backgroundColor = UIColor.blackColor()
        logButton.layer.cornerRadius = 5
        self.addSubview(logButton)
    }

    
}
